package com.core.spring;

public class IocBeanFactory implements MyApplicationContextInter {
    private static boolean isJar = false;
    private static volatile MyApplication application = new DefaultMyApplication(isJar);

    @Override
    public void set(MyApplication application) {
        if (IocBeanFactory.application == null) {
            IocBeanFactory.application = new DefaultMyApplication(isJar);
        }
    }

    public static synchronized void refresh(boolean jar) {
        if (jar != isJar) {
            isJar = jar;
            application = new DefaultMyApplication(isJar);
        }
    }

    public static MyApplication getInstant() {
        return application;
    }

    public static MyApplication getInstant(boolean jar) {
        refresh(jar);
        return application;
    }

}
